package com.ebao.po;

import java.io.Serializable;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

/**
 * @desc 区域
 * 
 * 地名有重复，不能根据地名找父级地名，可能会不只一个
 * 
 * eg. 江西省  南昌市  南昌县
 * 这3级以下的地区不保存在此表中，另外记录，需要用户手动输入
 * 
 * @author snow
 * @date 2012-6-29
 */
@Entity
@Table(name = "T_Area")
public class TArea implements Serializable {

	private static final long serialVersionUID = 1423685805579240347L;
	
	private Integer id;
	private String address; 	// 地名
	private TArea parent; 		// 上级地点
	private Integer priority; 	// 排序,比如在同一个省份下面有多个市，这些市需要通过这个字段进行排序
	private String valid; 		// 0有效,1无效,通过该字段可以设置某些地区暂时不开放

	@Id
	@GeneratedValue
	public Integer getId() {
		return id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	public String getAddress() {
		return address;
	}

	public void setAddress(String address) {
		this.address = address;
	}

	@Column(length = 3)
	public Integer getPriority() {
		return priority;
	}

	public void setPriority(Integer priority) {
		this.priority = priority;
	}

	@ManyToOne(cascade = { CascadeType.ALL }, optional = true, targetEntity = TArea.class)
	@JoinColumn(name = "parent_id")
	public TArea getParent() {
		return parent;
	}

	public void setParent(TArea parent) {
		this.parent = parent;
	}

	@Column(length = 1)
	public String getValid() {
		return valid;
	}

	public void setValid(String valid) {
		this.valid = valid;
	}

}
